﻿#region Copyright

// All Material Copyright © 2010 Dynamic Concepts Development Corp., All Rights Reserved.
//      Portions Copyright © 1984-2009 Dynamic Concepts Development Corp., All Rights Reserved.
// For further information please contact: SoftwareSupport@dynconcepts.com
// Dynamic Concepts Development Corp.  311 W 57th St. Suite #422, New York, NY 10019

#endregion

#region Using References

using System;

#endregion

namespace DynConDevCorp.OpenArch.SupportLibrary.ParallelExecution.Events
{
    public class ParallelEventHandler<TARGS> : IEquatable<ParallelEventHandler<TARGS>> where TARGS : EventArgs
    {
        #region Constructors

        public ParallelEventHandler(EventHandler<TARGS> internalHandler)
        {
            r_InternalHandler = internalHandler;
        }

        #endregion

        #region Public Methods

        public bool Equals(ParallelEventHandler<TARGS> other)
        {
            if (other == null) return false;
            if (ReferenceEquals(this, other)) return true;
            return r_InternalHandler == other.r_InternalHandler;
        }

        #endregion

        #region Internal Methods

        internal void Execute(object sender, TARGS args)
        {
            r_InternalHandler(sender, args);
        }

        #endregion

        #region Instance Fields (ReadOnly)

        private readonly EventHandler<TARGS> r_InternalHandler;

        #endregion
    }
}